﻿@* Generator: MvcHelper *@
@using System.Web.Optimization
@using MvcApplication1.Models
@helper Do(HtmlHelperContext context, RFunc first, RFunc second)
{
    <!DOCTYPE html>
    <html>
    <head>
        <title>title</title>
    </head>
    <body>
        <div id="_up001" style="border: 2px double black;">
            @first(new RVoid())
        </div>
        <div id="_up002" style="border: 2px double black;">
            @second(new RVoid())
        </div>
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/Scripts/jquery.ba-bbq.js")
        @Scripts.Render("~/Scripts/JavaScript1.js")
        <script>
            $(function () {
                function loadByAjax(fromReady) {
                    var hash = window.location.hash;
                    var urlFragment = hash ? hash.substring(1) : hash;
                    if (urlFragment)
                        $.ajax({
                            type: "POST",
                            dataType: "json",
                            cache: false,
                            url: urlFragment ? urlFragment : undefined,
                            data: {},
                            success: function (data) {
                                $.each(data, function (index, value) {
                                    $("#" + value.DivId).html(value.Html);
                                });
                            },
                            error: function (jqXHR, textStatus, errorThrow) {
                                alert("Request failed: " + textStatus + ", " + errorThrow);
                            }
                        });
                    else if (!fromReady)
                        location.reload();
                }
                $(window).bind('hashchange', function (e) {
                    loadByAjax(false);
                });
                loadByAjax(true);
            });
        </script>
    </body>
    </html>    
}
